//
//  CoustomPresentViewController.swift
//  taurus
//
//  Created by 刘艺 on 2021/10/18.
//  Copyright © 2021 com.fiture. All rights reserved.
//

import UIKit

class PageAController: UIViewController {

    lazy var presentView: UIButton = {
        let button = UIButton()
        button.setTitle("present view", for: .normal)
        button.addTarget(self, action:
                         #selector(presentView_), for: .touchUpInside)
        button.backgroundColor = UIColor.orange
        return button
    }()

    lazy var presentVC: UIButton = {
        let button = UIButton()
        button.setTitle("present vc", for: .normal)
        button.addTarget(self, action: #selector(presentVC_), for: .touchUpInside)
        button.backgroundColor = UIColor.orange
        return button
    }()

    lazy var presentNav: UIButton = {
        let button = UIButton()
        button.setTitle("present nav", for: .normal)
        button.addTarget(self, action: #selector(presentNav_), for: .touchUpInside)
        button.backgroundColor = UIColor.orange
        return button
    }()
    
    lazy var presentWrapNav: UIButton = {
        let button = UIButton()
        button.setTitle("present wrap nav", for: .normal)
        button.addTarget(self, action: #selector(presentWrapNav_), for: .touchUpInside)
        button.backgroundColor = UIColor.orange
        return button
    }()
    
    lazy var presentDoubleNav: UIButton = {
        let button = UIButton()
        button.setTitle("present double nav", for: .normal)
        button.addTarget(self, action: #selector(presentDoubleNav_), for: .touchUpInside)
        button.backgroundColor = UIColor.orange
        return button
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUI()
    }

    func setupUI() {
        view.backgroundColor = UIColor.white
        view.addSubview(presentView)
        view.addSubview(presentVC)
        view.addSubview(presentNav)
        view.addSubview(presentWrapNav)
        view.addSubview(presentDoubleNav)

        presentView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(100)
            make.size.equalTo(CGSize(width: 200, height: 60))
        }
        presentVC.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(presentView.snp.bottom).offset(50)
            make.size.equalTo(CGSize(width: 200, height: 60))
        }
        presentNav.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(presentVC.snp.bottom).offset(50)
            make.size.equalTo(CGSize(width: 200, height: 60))
        }
        
        presentWrapNav.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(presentNav.snp.bottom).offset(50)
            make.size.equalTo(CGSize(width: 200, height: 60))
        }
        
        presentDoubleNav.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(presentWrapNav.snp.bottom).offset(50)
            make.size.equalTo(CGSize(width: 200, height: 60))
        }
    }

    
    /// present 视图
    @objc func presentView_() {
        let testView = UIView()
        testView.backgroundColor = .yellow
        let manager = FitureCustomPresentManager(addPresentingViewController: self,
                                                 addPresentedView: testView)
        manager.present(animated: true, completion: nil)
    }
    
    /// present 控制器
    @objc func presentVC_() {
        let vc = PageBController()
        let manager = FitureCustomPresentManager(addPresentingViewController: self,
                                                 addPresentedViewController: vc)
        manager.present(animated: true, completion: nil)
    }

    /// 内部导航栏
    @objc func presentNav_() {
        let vc = PageBController()
        let config = FitureCustomPresentConfig(needNav: true,
                                               needCloseBtn:false,
                                               customHeightStyle: .customContainerHeight(600))
        let manager = FitureCustomPresentManager(addPresentingViewController: self,
                                                 addPresentedViewController: vc,
                                                 presentConfig: config)
        manager.present(animated: true, completion: nil)
    }
    
    /// 外部导航栏
    @objc func presentWrapNav_() {
        let vc = PageBController()
        let config = FitureCustomPresentConfig(title: "custom title",
                                               needWrapNav: true,
                                               needCloseBtn: false,
                                               customHeightStyle: .customContainerHeight(600))
        let manager = FitureCustomPresentManager(addPresentingViewController: self,
                                                 addPresentedViewController: vc,
                                                 presentConfig: config)
        manager.present(animated: true, completion: nil)
    }
    
    /// 先内部push、再外部push
    @objc func presentDoubleNav_() {
        let vc = PageBController()
        vc.isDoublePush = true
        let config = FitureCustomPresentConfig(title: "custom title",
                                               needNav: true,
                                               needWrapNav: true,
                                               needCloseBtn: false,
                                               customHeightStyle: .customContainerHeight(600))
        let manager = FitureCustomPresentManager(addPresentingViewController: self,
                                                 addPresentedViewController: vc,
                                                 presentConfig: config)
        manager.present(animated: true, completion: nil)
    }
}
